import axios from 'axios'
import querystring from 'querystring'

axios.defaults.baseURL = "http://192.168.1.3:3000";
axios.defaults.timeout = 5000;
/***
 * 请求拦截器，将其转化为表单形式提交
 */
axios.interceptors.request.use(config => {
  if (config.data && config.data.hasOwnProperty('isOpen')) {
    config.headers['Content-Type'] = 'application/json';
  } else {
    config.data = querystring.stringify(config.data);
    config.headers['Content-Type'] = 'application/x-www-form-urlencoded';
  }
  return config
}, err => {
  return Promise.reject(err)
});
axios.interceptors.response.use(response => {
  return response
}, err => {
  return Promise.reject(err)
});

export default {
  register(data){
    return axios.post('/user/register',data);
  }
}

